//
//  AppDelegate.m
//  07-UITabBarController
//
//  Created by 王道林 on 16/7/22.
//  Copyright © 2016年 王道林. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    _window.backgroundColor = [UIColor whiteColor];
    [_window makeKeyAndVisible];
    UITabBarController *tabBar = [[UITabBarController alloc] init];
    _window.rootViewController = tabBar;
    
    
    ViewController *vc = [ViewController new];
    
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:vc];
    [tabBar setViewControllers:@[navigation]];
    // 设置tabBarItem时, 给你要放进数组中的控制器去赋值
    vc.navigationController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:nil tag:200];
    
    //  设置标题
    vc.navigationItem.title = @"NEWS";
    
    
    
    
    
    
    
#if 0
    // UITabBarController 标签视图控制器
    //主要管理 没有层级关系的视图控制器
    // 1. viewControllers  所有被管理的视图控制器,都在这个数组中可以通过setter方法赋值 也可以通过下述的方法进行视图控制器数组的赋值
    // 2 . setViewConteroller:animated;
    //3.通过一组数组创建完成后 如果数组中的控制器
    //4.tabbarItem 根据自己需求去创建对应tabbarItem
    // UIViewController的属性(category)
    //因为每个视图控制器的TabBarItem都不一样 因此不能设为TabBarController的属性
    //
    //创建方式
    //1> initWithTabBarsystemitem:tag 根据系统样式创建
    //2> initWithtitle:image:tag 根据自定义的图片创建
    //3> initWithtitle:image:selectedimage:tag 根据自定义的文字和图片创建 增添选中图片
    
    //5.如果数组个数过多 多于5 系统会把多余出来的内容 统一使用去管理
    //建议:数组个数不要大于5
    
    // 6. tabBar(高度 是 49)
    //  1> barTintColor   bar的颜色
    tabBar.tabBar.barTintColor = [UIColor greenColor];
    
    // 2 >tintColor    bar上元素的颜色
    
    tabBar.tabBar.tintColor = [UIColor blackColor];
    
    //3>  translucent  bar是否半透明
    
    // 7 UIAppearance 全局设置  类调用的
    [[UITabBar appearance] setTintColor:[UIColor yellowColor]];
    
    [[UINavigationBar appearance] setTintColor:[UIColor orangeColor]];
    
    //修改系统标题颜色
    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
    
    
    // VC中  self.title  与 self.navigationItem.title的 区别
    // 1>  self.title会修改俩个内容,  navigationItem.title 和 tabBarItem.title
    // 2>  self.navigationItem.title只修改navigationBar上的标题
    
    
    
    ViewController *vc1 = [[ViewController alloc] init];
    UINavigationController *navigation = [[UINavigationController alloc] initWithRootViewController:vc1];
    
    vc1.view.backgroundColor = [UIColor redColor];
    vc1.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"新闻" image:nil tag:100];
    vc1.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:100];
    //  badge标记 未读消息  badgeValue角标
    vc1.tabBarItem.badgeValue = @"100";
    
    ViewController *vc2 = [[ViewController alloc] init];
    vc2.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"视频" image:nil tag:200];
    vc2.view.backgroundColor = [UIColor greenColor];
    ViewController *vc3 = [[ViewController alloc] init];
    vc3.view.backgroundColor = [UIColor grayColor];
    vc3.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发现" image:nil tag:300];
    ViewController *vc4 = [[ViewController alloc] init];
    vc4.view.backgroundColor = [UIColor blueColor];
    vc4.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人" image:nil tag:400];
    
    [tabBar setViewControllers:@[navigation, vc2, vc3, vc4]];

#endif
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
